package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.activity.client.ActivityFeignClient;
import com.atguigu.gmall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * @author: 李旭
 * @create: 2021-09-17 15:38
 **/
@Controller
public class ActivityCotnroller {

    @Autowired
    private ActivityFeignClient activityFeignClient;
    //进入秒杀频道页面
    @GetMapping("/index")
    public String index(Model model){
        List<SeckillGoods> seckillGoodsList = activityFeignClient.getSeckillGoodsList();
        model.addAttribute("list",seckillGoodsList);
        return "seckill/index";
    }
    //进入秒杀详情页面
    @GetMapping("/seckill/{skuId}.html")
    public String seckillDetail(@PathVariable String skuId,Model model){
        SeckillGoods item = activityFeignClient.getItem(skuId);
        model.addAttribute("item",item);
        return "seckill/item";
    }

    //进入秒杀抢购页面
    @GetMapping("/seckill/queue.html")
    public String seckillQueue(Long skuId,String skuIdStr,Model model){
        model.addAttribute("skuId",skuId);
        model.addAttribute("skuIdStr",skuIdStr);
        return "seckill/queue";
    }
}
